//提供属性访问方法
function Person() {
  this.name = 'abc';
  this.age = 18;
  this.getAge = function () {
    return this.age;
  }
}

const p1 = new Person();
const a = p1.getAge();


//属性外部可见,能直接访问(优)
function Person() {
  this.name = "abc";
  this.age = 18;
}

const p2 = new Person();
const b = p2.age;